Skip to content

Conversation

@dconeybe
Copy link
Contributor

Android and iOS do not have a way to take command-line arguments as input, and therefore there is no way to specify useful arguments like --gtest_test_filter when developing/debugging a specific test. This PR modifies firebase_test_framework.cc to at least provide an easy way to hardcode googletest arguments during development.

@dconeybe dconeybe self-assigned this May 13, 2021
@google-cla google-cla bot added the cla: yes label May 13, 2021
@dconeybe dconeybe added the tests-requested: quick Trigger a quick set of integration tests. label May 13, 2021
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. tests: failed This PR's integration tests failed. and removed tests-requested: quick Trigger a quick set of integration tests. labels May 13, 2021
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label May 13, 2021
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. tests: succeeded This PR's integration tests succeeded. and removed tests: failed This PR's integration tests failed. labels May 14, 2021
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label May 14, 2021
@dconeybe dconeybe requested review from ehsannas and jonsimantov and removed request for jonsimantov May 14, 2021 13:57
@dconeybe dconeybe assigned ehsannas and unassigned dconeybe May 14, 2021
Copy link
Contributor

@ehsannas ehsannas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is generally useful. I used this method when I was trying to reproduce an issue for a specific test. A minor suggestion inlined.

Also a couple of questions for my own benefit:

Are the changes clang-formatted? (If not, does GitHub automatically format it before merging?)

How is this firebase_test_framework invoked? The cleaner approach seems to be to pass --gtest_filter to that invocation (so that it's already in argv when we get to common_main)


// Write the elements of the vector back into argv and modify argc.
// The memory leaks produced below are acceptable because they would last the
// entire lifetime of the application anyways.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More importantly, I would say they are acceptable because this may only be used during development / debugging.

We could alter the code slightly so that it doesn't leak memory except for when someone is adding new flags during dev/debugging process. Meaning, we could add an early exit here:

if (args_vector.size() == argc) {
  return argv;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I've implemented this suggestion and refactored the code a bit. PTAL.

@dconeybe
Copy link
Contributor Author

dconeybe commented May 14, 2021

Are the changes clang-formatted? (If not, does GitHub automatically format it before merging?)

Yes, the file has been formatted with clang-format. GitHub does not automatically format but there is a presubmit check that verifies that code is formatted correctly and also an (optional) commit hook that you can install locally. See #380 for details.

How is this firebase_test_framework invoked? The cleaner approach seems to be to pass --gtest_filter to that invocation (so that it's already in argv when we get to common_main)

It would definitely be cleaner to just specify arguments on the command line. You can indeed do this when running the desktop tests. However, Android has no means of specifying command-line arguments and we have not plumbed through the command-line arguments in iOS (if it's even possible). There are probably some platform-specific mechanisms that could be used to specify the arguments without having to edit source code; however, this is just a quick-and-dirty way to get it done.

@ehsannas
Copy link
Contributor

Got it. Thanks

@dconeybe dconeybe requested a review from ehsannas May 18, 2021 04:20
@dconeybe dconeybe added the tests-requested: quick Trigger a quick set of integration tests. label May 18, 2021
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. and removed tests-requested: quick Trigger a quick set of integration tests. tests: succeeded This PR's integration tests succeeded. labels May 18, 2021
@github-actions
Copy link

github-actions bot commented May 18, 2021

✅  Integration test succeeded!

Requested by @dconeybe on commit 8165fad
Last updated: Mon May 17 23:17:17 PDT 2021
View integration test results

@github-actions github-actions bot added the tests: succeeded This PR's integration tests succeeded. label May 18, 2021
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label May 18, 2021
@ehsannas ehsannas assigned dconeybe and unassigned ehsannas May 19, 2021
@dconeybe dconeybe merged commit 94df73a into main May 19, 2021
@dconeybe dconeybe deleted the dconeybe/GoogletestArgsForAndroidAndIos branch May 19, 2021 14:21
@firebase firebase locked and limited conversation to collaborators Jun 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes tests: succeeded This PR's integration tests succeeded.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants